package com.my;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 过滤敏感字
 * <p>
 * Created by YJH on 2017/7/13 20:15.
 */
public class ContentFilter extends HttpFilter {

    @Override
    public void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws IOException, ServletException {
        //1.获取请求content参数的值
        String content = request.getParameter("content");

        //2.把其中fuck，shit 等字符串替换为 ***
        HttpServletRequest req = new MyHttpServletRequest(request);

        //3.转到目标页面
        filterChain.doFilter(req, response);
    }
}
